package lifei.lifei.mybatis.jdbcdemo;

import lifei.lifei.mybatis.common.JdbcUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class LinkTabUpdate {
    public static void main(String[] args) throws SQLException {
        //注册驱动
        //获取链接
        Connection conn = JdbcUtils.getConn();
        //定义SQL
        String sql = "update sys_logs set operation = ?,params=? where id = ?";
        //创建传输器
        PreparedStatement ps = conn.prepareStatement(sql);
        //设置占位符
        ps.setObject(1, "权限操作");
        ps.setObject(2, "zwx");
        ps.setObject(3, 41);
        //执行SQL
        int rows = ps.executeUpdate();
        //处理结果集
        if (rows > 0 ){
            System.out.println("更新成功");
        }else {
            System.out.println("更新失败");
        }
        //关闭资源
        JdbcUtils.clocesIO(ps);
        JdbcUtils.clocesIO(conn);
    }
}
